Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Field edit hook crashes if custom fields enabled for option values #1016

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

ufundo
Copy link
Contributor

@ufundo ufundo commented Oct 25, 2024

Overview

Just updating this one call from api3 to api4 seems to fix it.

It seems that in the Custom Field edit hook this call with api3 attempts to access the custom field before it's fully created, causing a fatal. You are left with a half created custom field, which causes general havoc on your system.

With api4, no such problem.

Steps to reproduce (D10, at least as far back as Civi 5.75, also on Civi master)

# enable adding custom fields to OptionValues
cv api4 OptionValue.create +v option_group_id.name=cg_extend_objects +v label=OptionValue +v value=OptionValue +v name=civicrm_option_value

# create a custom group that extends OptionValues
cv api4 CustomGroup.create +v name=test_group +v title=test_group +v extends=OptionValue

# create a custom field in that group
cv api4 CustomField.create +v custom_group_id.name=test_group +v html_type=Text +v label=test_field

Before


In api.php line 149:
                           
  DB Error: no such field  
                           

After

  • Field creates as expected

Comments

Admittedly custom fields on OptionValues is a bit of a strange situation, but it seems to generally work fine apart from this.

@KarinG
Copy link
Collaborator

KarinG commented Oct 25, 2024

I've added you to the whitelist to kick off the tests.

@ufundo
Copy link
Contributor Author

ufundo commented Oct 25, 2024

Thanks!

@KarinG KarinG merged commit e110bff into colemanw:6.x Oct 25, 2024
3 of 4 checks passed
@KarinG
Copy link
Collaborator

KarinG commented Oct 25, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants